<?php 
$sql = "SELECT `Total Population`,`White` , `Black or African American` , `American Indian and Alaska Native` , `Asian` , `Native Hawaiian and Other Pacific Islander` , `Some Other Race` , `Two or More Races` FROM `ZipCode Profile1` as race WHERE `ZCTA5` = $zipcode";
$result = mysql_query($sql,$db);
$num_rows = mysql_num_rows($result);
if ($result)
{
	$result_row = mysql_fetch_array($result,MYSQL_ASSOC);
	if($result_row)
	{
		$white_pop = $result_row['White'];
		$african_american_pop = $result_row['Black or African American'];
		$american_indian_pop = $result_row['American Indian and Alaska Native'];
		$asian_pacificislander_pop = $result_row['Asian'] + $result_row['Native Hawaiian and Other Pacific Islander'];
		$other_pop= $result_row['Some Other Race'] ;
		$mixec_pop =  $result_row['Two or More Races'] ;
		$total_pop = $result_row['Total Population'] ;
		
	}
}

if($total_pop != 0)
{
$white_percet = number_format((100*$white_pop)/$total_pop,2);
$african_american_percet = number_format((100*$african_american_pop)/$total_pop,2);
$american_indian_percet = number_format((100*$american_indian_pop)/$total_pop,2);
$asian_pacificislander_percet = number_format((100*$asian_pacificislander_pop)/$total_pop,2);
$other_percet = number_format((100*$other_pop)/$total_pop,2);
$mixec_percet = number_format((100*$mixec_pop)/$total_pop,2);


echo "<Table width=250px cellspacing='-1' bordar=0>";
      echo "<tr style='width:100%; background:#F5DEB3; font-size:12px'>";
	  echo "<td>White: ";
	  echo "</td>";
	  echo "<td align='right' nowrap='nowrap'>".$white_pop." (".$white_percet."%)";
	  echo "</td>";
	  echo "</tr>";
	  
	  echo "<tr style='width:100%;font-size:12px'>";
	  echo "<td>African American: ";
	  echo "</td>";
	  echo "<td align='right' nowrap='nowrap'>".$african_american_pop." (".$african_american_percet."%)";
	  echo "</td>";
	  echo "</tr>";
	  
	  echo "<tr style='width:100%; background:#F5DEB3; font-size:12px'>";
	  echo "<td>American Indian: ";
	  echo "</td>";
	  echo "<td align='right' nowrap='nowrap'>".$american_indian_pop." (".$american_indian_percet."%)";
	  echo "</td>";
	  echo "</tr>";
	  
	  echo "<tr style='width:100%;font-size:12px'>";
	  echo "<td>Asian & Pacific Islander: ";
	  echo "</td>";
	  echo "<td align='right' nowrap='nowrap'>".$asian_pacificislander_pop." (".$asian_pacificislander_percet."%)";
	  echo "</td>";
	  echo "</tr>";
	  
	  echo "<tr style='width:100%; background:#F5DEB3; font-size:12px'>";
	  echo "<td>Others: ";
	  echo "</td>";
	  echo "<td align='right' nowrap='nowrap'>".$other_pop." (".$other_percet."%)";
	  echo "</td>";
	  echo "</tr>";
	  
	  echo "<tr style='width:100%;font-size:12px'>";
	  echo "<td>Mixed Races: ";
	  echo "</td>";
	  echo "<td align='right' nowrap='nowrap'>".$mixec_pop." (".$mixec_percet."%)";
	  echo "</td>";
	  echo "</tr>";
echo "</Table>";
}
else
{
$nodata_msg = "Data is not available.  Please make sure the City, State and Zipcode Information is correct.";

echo "<Table width=250px cellspacing='-1' bordar=0>";
      echo "<tr style='width:100%; background:#F5DEB3; font-size:12px'>";
	  echo "<td align='right' nowrap='nowrap'>".$nodata_msg;
	  echo "</td>";

	  echo "</Table>";


}
?>
